﻿using iTextSharp.text.pdf;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharp.Infrastructure
{
    public class PdfHelper
    {
        public string ReadPdf(string path)
        {
            StringBuilder text = new StringBuilder();
            PdfReader pdfReader = new PdfReader(path);
            int numberOfPages = pdfReader.NumberOfPages;
            for (int i = 1; i <= numberOfPages; ++i)
            {
                text.Append(iTextSharp.text.pdf.parser.PdfTextExtractor.GetTextFromPage(pdfReader, i));
            }

            pdfReader.Close();

            return text.ToString();
        }
    }
}
